package br.usp.icmc.dilvan.aimTemplateViewer.client;

import java.util.List;

import br.usp.icmc.dilvan.aimTemplateViewer.client.aimTemplate.ComponentAIMTemplate;
import br.usp.icmc.dilvan.aimTemplateViewer.client.impl.ComponentAIMImpl;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.DockLayoutPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.RootLayoutPanel;
import com.google.gwt.user.client.ui.VerticalPanel;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class AIMTemplateViewer implements EntryPoint {

	/**
	 * This is the entry point method.
	 */
	public void onModuleLoad() {
		
		String content= DOM.getElementById("AIMTemplate").getInnerHTML();
		String templateName= "LIDC CT";
		
		//String content= GlobalResources.INSTANCE.vASARITemplatesV1rv233MixedModalities().getText();
		System.out.println(content);
		
		VerticalPanel componentsPanel= new VerticalPanel();
		List<ComponentAIMTemplate> components= AIMTemplateParser.parseTemplate(content, templateName).getComponents();
		for (ComponentAIMTemplate component : components) {
			componentsPanel.add(new ComponentAIMImpl(component));
		}
	
		DockLayoutPanel p = new DockLayoutPanel(Unit.EM);
		p.addNorth(new HTML("<b>Showing Template</b>"), 2);
		p.add(componentsPanel);
		RootLayoutPanel.get().add(p);
	}
}
